package com.miaoji.controller;

import com.miaoji.domain.po.Combo;
import com.miaoji.domain.po.ComboDetail;
import com.miaoji.domain.vo.ComboVo;
import com.miaoji.mapper.ComboDetailMapper;
import com.miaoji.service.ComboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/combo")
public class ComboManagementController {
    @Autowired
    ComboService comboService;

    @GetMapping("/init")
    public List<ComboVo> comboInit() {
        return  comboService.ComboselectAllList();
    }

    @GetMapping("/select")
    public List<Combo> comboSelect(@RequestBody Combo combo) {
        return comboService.ComboSelect(combo);
    }

    @GetMapping("/detail")
    public List<ComboDetail> comboDetails(@RequestBody Combo combo) {
        return comboService.ComboDetailSelect(combo);
    }

    @PostMapping("/insert")
    public void comboInsert(@RequestBody Combo combo) {
        comboService.ComboNew(combo);
    }

    @PostMapping("/insert-detail")
    public void comboInsertDetail(@RequestBody ComboDetail comboDetail) {
        comboService.ComboDetaileNew(comboDetail);
    }

    @PostMapping("/update")
    public void comboUpdate(@RequestBody Combo combo) {
        comboService.ComboUpdate(combo);
    }

    @PostMapping("/update-details")
    public void comboDetailUpdate(@RequestBody ComboDetail comboDetail) {
        comboService.ComboDetailUpdate(comboDetail);
    }

    @PostMapping("/delete")
    public void comboDelete(@RequestBody Combo combo) {
        comboService.ComboDelete(combo);
    }

    @PostMapping("/delete-detail")
    public  void comboDelete(@RequestBody ComboDetail comboDetail){
        comboService.ComboDetailDelete(comboDetail);
    }
}
